using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.IO;
using NetWorkMsg;

namespace NetMsg.Hatch
{
    // 前4个枚举和龙的类型枚举保持一致
    public enum EggType
    {
        Ice,
        Fire,
        Storm,
        Poison,
        Undefined,
    }
    
    // 蛋
    public class EggInfo : IUnPackable
    {
        public int EggId;
        // 1 代表未知结晶
        public int CfgId;
        // 是否已解析
        public bool Analyzed;
        // 槽(配置Id)
        public List<EggType> Slot;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            EggId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
            UnPackAuxiliary.Read(stream, out Analyzed);
            UnPackAuxiliary.Read(stream, out uint var2);
            Slot = new List<EggType>((int)var2);
            for(var i = 0; i < var2; ++i)
            {
                UnPackAuxiliary.Read(stream, out uint var3);
                Slot.Add((EggType)var3);
            }
        }
    }
    
    // 孵化中的蛋
    public class HatchEggInfo : IUnPackable
    {
        public int EggId;
        public int CfgId;
        // 是否已解析
        public bool Analyzed;
        // 槽(配置Id)
        public List<EggType> Slot;
        // 已经献计了的蛋(配置Id)
        public List<int> Sacrifices;
        // 时间戳(剩余孵化时间)
        public int HatchTime;
        // 成长值
        public int GrowthExp;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            EggId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            CfgId = (int)var1;
            UnPackAuxiliary.Read(stream, out Analyzed);
            UnPackAuxiliary.Read(stream, out uint var2);
            Slot = new List<EggType>((int)var2);
            for(var i = 0; i < var2; ++i)
            {
                UnPackAuxiliary.Read(stream, out uint var3);
                Slot.Add((EggType)var3);
            }
            UnPackAuxiliary.ReadUsAsIs(stream, out Sacrifices);
            UnPackAuxiliary.Read(stream, out uint var4);
            HatchTime = (int)var4;
            UnPackAuxiliary.Read(stream, out uint var5);
            GrowthExp = (int)var5;
        }
    }
    
    // 获得数据
    public struct GetHatchInfoQ : IServerCallbackable
    {
        
        public uint UnPackableId => 90;
        public uint PackableId => 121;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 121u);
        }
    }
    
    public class GetHatchInfoP : IUnPackable
    {
        public List<EggInfo> Eggs;
        
        public const uint Sid = 90;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Eggs = new List<EggInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new EggInfo();
                var1.UnPack(stream);
                Eggs.Add(var1);
            }
        }
    }
    
    // 获得孵蛋数据
    public struct GetHatchEggInfoQ : IServerCallbackable
    {
        public int EggId;
        
        public uint UnPackableId => 91;
        public uint PackableId => 122;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 122u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    public class GetHatchEggInfoP : IUnPackable
    {
        public HatchEggInfo HatchEgg;
        
        public const uint Sid = 91;
        
        public void UnPack(MemoryStream stream)
        {
            HatchEgg = new HatchEggInfo();
            HatchEgg.UnPack(stream);
        }
    }
    
    public enum IdentifyResult
    {
        // 成功
        Succ,
        // 金钱不够
        NeedMoreGold,
        // 其他异常
        Other,
    }
    
    // 鉴定
    public struct IdentifyQ : IServerCallbackable
    {
        public int EggId;
        
        public uint UnPackableId => 92;
        public uint PackableId => 123;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 123u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    public class IdentifyP : IUnPackable
    {
        public int CfgId;
        // 槽(配置Id)
        public List<EggType> Slot;
        public IdentifyResult Result;
        
        public const uint Sid = 92;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            CfgId = (int)var0;
            UnPackAuxiliary.Read(stream, out uint var1);
            Slot = new List<EggType>((int)var1);
            for(var i = 0; i < var1; ++i)
            {
                UnPackAuxiliary.Read(stream, out uint var2);
                Slot.Add((EggType)var2);
            }
            UnPackAuxiliary.Read(stream, out uint var3);
            Result = (IdentifyResult)var3;
        }
    }
    
    // 出售
    public struct SellQ : IIdPackable
    {
        public int EggId;
        
        public uint PackableId => 124;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 124u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    // 解析结果
    public enum AnalyzeResult
    {
        Succ,
        // 钻石不够
        NeedMoreDiamon,
    }
    
    // 解析
    public struct AnalyzeQ : IServerCallbackable
    {
        public int EggId;
        
        public uint UnPackableId => 93;
        public uint PackableId => 125;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 125u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    public struct AnalyzeP : IUnPackable
    {
        public AnalyzeResult Result;
        
        public const uint Sid = 93;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (AnalyzeResult)var0;
        }
    }
    
    public enum HatchResult
    {
        Success,
        // 达到上限
        Limit,
        // 没有这个蛋
        None,
        // 未鉴定
        Undefined,
    }
    
    // 孵化 
    public struct HatchQ : IServerCallbackable
    {
        public int EggId;
        
        public uint UnPackableId => 94;
        public uint PackableId => 126;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 126u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    public struct HatchP : IUnPackable
    {
        public HatchResult Result;
        
        public const uint Sid = 94;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            Result = (HatchResult)var0;
        }
    }
    
    // 献祭
    public struct SacrificeQ : IIdPackable
    {
        public int Slot;
        // 正在孵化的蛋
        public int EggId;
        // 被献祭的蛋的Id
        public int Victim;
        
        public uint PackableId => 127;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 127u);
            PackAuxiliary.Write(stream, (uint)Slot);
            PackAuxiliary.Write(stream, (uint)EggId);
            PackAuxiliary.Write(stream, (uint)Victim);
        }
    }
    
    // 砸蛋
    public struct SmashEggQ : IIdPackable
    {
        public int EggId;
        
        public uint PackableId => 128;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 128u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    // 加速
    public class SpeedUpQ : IIdPackable
    {
        public int EggId;
        
        public uint PackableId => 129;
        
        public void Pack(MemoryStream stream)
        {
            PackAuxiliary.Write(stream, 129u);
            PackAuxiliary.Write(stream, (uint)EggId);
        }
    }
    
    public class NoticeNewEggsP : IUnPackable
    {
        public List<EggInfo> News;
        
        public const uint Sid = 95;
        
        public void UnPack(MemoryStream stream)
        {
            UnPackAuxiliary.Read(stream, out uint var0);
            News = new List<EggInfo>((int)var0);
            for(var i = 0; i < var0; ++i)
            {
                var var1 = new EggInfo();
                var1.UnPack(stream);
                News.Add(var1);
            }
        }
    }
    
    public enum HatchEnum
    {
        GetHatchInfoP,
        GetHatchEggInfoP,
        IdentifyP,
        AnalyzeP,
        HatchP,
        NoticeNewEggsP,
    }
}
